/**
 *     This file is part of cesm-ws.
 *
 *     cesm-ws, Web Service for Community Earth System Model
 *
 *     Copyright (c) 2010, Purdue University and/or affilicates or thrid-party contributors as
 *     indicated by the @author tags or express copyright attribution statements
 *     applied by the authors. All third-party contributions are distributed under
 *     license by Purdue University.
 *
 *     cesm-ws is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this distribution.  If not, see <http://www.gnu.org/licenses/>.
 */

package edu.purdue.rcac.cesm;

import edu.purdue.rcac.cesm.define.ComponentSet;


/**
 * This class stores informations that will be shared for components of cesm,
 * which includes:
 * <ul>
 * <li>cesm-ws-interface</li>
 * <li>cesm-ws-facade</li>
 * </ul>
 * 
 * @author Han Zhang
 * 
 */
public class Constants {
	public static final String APP_NAME = "cesm";
	public static final String PARAM = "param";
	public static final String PBSID = "pbsid";

	public static enum ParamName {
		ACTION, USERNAME, CASENAME, PASSWORD, FILE, TOKEN;
		public ParamName fromString(String str) {
			return ParamName.valueOf(str.toUpperCase());
		}
	};

	public static enum EnvFile {
		env_conf, env_run, env_mach_pes, env_build, env_derived, env_mach_specific
	}

	public static final String[] StateTransitionActions = { "create_case",
			"configure_case", "reset_config", "run_case", "cancel_case" };

	public static final String DELIMITOR = ":";

	public static String wrapParam(String param) {
		return String.format("%s%s%s", PARAM, DELIMITOR, param);
	}

	public static String unwrapParam(String wrappedParam) {
		if (wrappedParam.startsWith(PARAM + DELIMITOR)) {
			return wrappedParam.substring(PARAM.length() + DELIMITOR.length());
		} else {
			return null;
		}
	}

	public static void main(String[] args) {
		System.out.println(ComponentSet.fromString("I1850"));
	}

}